USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[BillsTypes-Insert]    Script Date: [[20120714223927]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223927]]
-- Description:	Insert record into table [dbo].[BillsTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[BillsTypes-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[BillsTypes-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[BillsTypes-Insert]
	/*@BillType_RowNumber int =Null OUTPUT , 
	@BillType_ID uniqueidentifier =Null  , 
	@BillType_Code varchar(50) =Null  , 
	@BillType_NameAr varchar(300) =Null  , 
	@BillType_NameEn varchar(300) =Null  , 
	@BillType_Notes varchar(max) =Null  , 
	@BillType_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[BillsTypes](/*[BillType_ID], [BillType_Code], [BillType_NameAr], [BillType_NameEn], [BillType_Notes], [BillType_Search]*/)
	VALUES     (/*@BillType_ID, @BillType_Code, @BillType_NameAr, @BillType_NameEn, @BillType_Notes, @BillType_Search*/)

	/*SELECT @BillType_RowNumber = [BillType_RowNumber]
    FROM [dbo].[BillsTypes]
    WHERE  ( [BillType_ID] =@BillType_ID )
	AND  ( [BillType_Code] =@BillType_Code )
	AND  ( [BillType_NameAr] =@BillType_NameAr )
	AND  ( [BillType_NameEn] =@BillType_NameEn )
	AND  ( [BillType_Notes] =@BillType_Notes )
	AND  ( [BillType_Search] =@BillType_Search )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[BillsTypes-update]    Script Date: [[20120714223927]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223927]]
-- Description:	Update record in table [dbo].[BillsTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[BillsTypes-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[BillsTypes-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[BillsTypes-update]
	/*@BillType_RowNumber int =Null OUTPUT , 
	@BillType_ID uniqueidentifier =Null  , 
	@BillType_Code varchar(50) =Null  , 
	@BillType_NameAr varchar(300) =Null  , 
	@BillType_NameEn varchar(300) =Null  , 
	@BillType_Notes varchar(max) =Null  , 
	@BillType_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/**/
		Update [dbo].[BillsTypes] SET 
		/*[BillType_ID] =@BillType_ID, 
		[BillType_Code] =@BillType_Code, 
		[BillType_NameAr] =@BillType_NameAr, 
		[BillType_NameEn] =@BillType_NameEn, 
		[BillType_Notes] =@BillType_Notes, 
		[BillType_Search] =@BillType_Search*/
		/*WHERE ([BillType_ID] = @BillType_ID)*/
	/**/

	/*SELECT @BillType_RowNumber = [BillType_RowNumber]
    FROM [dbo].[BillsTypes]
	WHERE ([BillType_ID] = @BillType_ID)*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[BillsTypes-Insert-Update]    Script Date: [[20120714223927]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223927]]
-- Description:	Insert OR Update record into table [dbo].[BillsTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[BillsTypes-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[BillsTypes-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[BillsTypes-Insert-Update]
	/*@BillType_RowNumber int =Null OUTPUT , 
	@BillType_ID uniqueidentifier =Null  , 
	@BillType_Code varchar(50) =Null  , 
	@BillType_NameAr varchar(300) =Null  , 
	@BillType_NameEn varchar(300) =Null  , 
	@BillType_Notes varchar(max) =Null  , 
	@BillType_Search varchar(max) =Null  , 
	@Inserted bit OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[BillsTypes] 
					/*WHERE ([BillType_ID] = @BillType_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[BillsTypes](/*[BillType_ID], [BillType_Code], [BillType_NameAr], [BillType_NameEn], [BillType_Notes], [BillType_Search]*/)
		VALUES     (/*@BillType_ID, @BillType_Code, @BillType_NameAr, @BillType_NameEn, @BillType_Notes, @BillType_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/**/
			Update [dbo].[BillsTypes] SET 
			/*[BillType_ID] =@BillType_ID, 
			[BillType_Code] =@BillType_Code, 
			[BillType_NameAr] =@BillType_NameAr, 
			[BillType_NameEn] =@BillType_NameEn, 
			[BillType_Notes] =@BillType_Notes, 
			[BillType_Search] =@BillType_Search*/
			/*WHERE ([BillType_ID] = @BillType_ID)*/
		/**/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @BillType_RowNumber = [BillType_RowNumber]
    FROM [dbo].[BillsTypes]
	WHERE ([BillType_ID] = @BillType_ID)*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[BillsTypes-Delete]    Script Date: [[20120714223927]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223927]]
-- Description:	delete records from table [dbo].[BillsTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[BillsTypes-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[BillsTypes-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[BillsTypes-Delete]
	/*@BillType_RowNumber int =null  , 
	@BillType_ID uniqueidentifier =null  , 
	@BillType_Code varchar(50) =null  , 
	@BillType_NameAr varchar(300) =null  , 
	@BillType_NameEn varchar(300) =null  , 
	@BillType_Notes varchar(max) =null  , 
	@BillType_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[BillsTypes]
	WHERE /*( [BillType_RowNumber] = ISNULL(@BillType_RowNumber, [BillType_RowNumber]) )
	AND ( [BillType_ID] = ISNULL(@BillType_ID, [BillType_ID]) )
	AND ( [BillType_Code] like ISNULL(@BillType_Code, [BillType_Code]) )
	AND ( [BillType_NameAr] like ISNULL(@BillType_NameAr, [BillType_NameAr]) )
	AND ( [BillType_NameEn] like ISNULL(@BillType_NameEn, [BillType_NameEn]) )
	AND ( [BillType_Notes] like ISNULL(@BillType_Notes, [BillType_Notes]) )
	AND ( [BillType_Search] like ISNULL(@BillType_Search, [BillType_Search]) )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[BillsTypes-Select]    Script Date: [[20120714223927]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223927]]
-- Description:	select records from table [dbo].[BillsTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[BillsTypes-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[BillsTypes-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[BillsTypes-Select]
	/*@BillType_RowNumber int =null  , 
	@BillType_ID uniqueidentifier =null  , 
	@BillType_Code varchar(50) =null  , 
	@BillType_NameAr varchar(300) =null  , 
	@BillType_NameEn varchar(300) =null  , 
	@BillType_Notes varchar(max) =null  , 
	@BillType_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[BillsTypes]
	WHERE /*( [BillType_RowNumber] = ISNULL(@BillType_RowNumber, [BillType_RowNumber]) )
	AND ( [BillType_ID] = ISNULL(@BillType_ID, [BillType_ID]) )
	AND ( [BillType_Code] like ISNULL(@BillType_Code, [BillType_Code]) )
	AND ( [BillType_NameAr] like ISNULL(@BillType_NameAr, [BillType_NameAr]) )
	AND ( [BillType_NameEn] like ISNULL(@BillType_NameEn, [BillType_NameEn]) )
	AND ( [BillType_Notes] like ISNULL(@BillType_Notes, [BillType_Notes]) )
	AND ( [BillType_Search] like ISNULL(@BillType_Search, [BillType_Search]) )*/
END
GO
-- =============================================
